package bank_access;

import java.io.Serializable;
import mware_lib.ObjectBroker;
import mware_lib.ObjectRef;

public class AccountProxy extends AccountImplBase {
  private ObjectRef refrence;
  
  public AccountProxy(ObjectRef rawObjectRef) {
    refrence = rawObjectRef;
  }
  
  @Override
  public void transfer(double amount) throws OverdraftException {
    Serializable result = ObjectBroker.instance().invokeRemoteMethod(refrence, "transfer", new Serializable[] { amount });
    if (result != null && result instanceof OverdraftException)
      throw (OverdraftException)result;
    if (result != null && result instanceof RuntimeException)
      throw (RuntimeException)result;
  }

  @Override
  public double getBalance() {
    Serializable result = ObjectBroker.instance().invokeRemoteMethod(refrence, "getBalance", new Serializable[] {});
    if (result != null && result instanceof RuntimeException)
      throw (RuntimeException)result;
    return (double)result;
  }
}